<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@page import="Util.Pkipair"%>

<!-- 分账修改 -->


<%
	//编码方式，1代表 UTF-8; 2 代表 GBK; 3代表 GB2312 默认为1,该参数必填。
	String inputCharset = "1";
	//网关版本，固定值：v2.0,该参数必填。
	String version =  "v2.0";
	//签名类型,该值为4，代表PKI加密方式,该参数必填。
	String signType =  "4";
	//原消费交易商户订单号
	String orderId = "KQ20220621165440";//new java.text.SimpleDateFormat("yyyyMMddHHmmss").format(new java.util.Date())+"dsfd";
	//手续费收款方的useId，默认为原收单分账请求中的手续费收款方
	String feePayer = "HAT_10012140356"; 
	//新分账明细
	String sharingData ="2^HAT_10012140356^3^1^异步分账1|2^HAT_10012138334^7^1^异步分账2";	
	
	//平台商户号
	String merchantAcctId= "1001214035601"; 
	

	
	// signMsg 签名字符串 不可空，生成加密签名串
	String signMsgVal = "";
	signMsgVal = appendParam(signMsgVal, "inputCharset", inputCharset);
	signMsgVal = appendParam(signMsgVal, "version", version);
	signMsgVal = appendParam(signMsgVal, "signType", signType);
	signMsgVal = appendParam(signMsgVal, "orderId", orderId);
	signMsgVal = appendParam(signMsgVal, "feePayer",feePayer);
	signMsgVal = appendParam(signMsgVal, "merchantAcctId",merchantAcctId);		
	signMsgVal = appendParam(signMsgVal, "sharingData", sharingData);

	System.out.println(signMsgVal);
	Pkipair pki = new Pkipair();
	String signMsg = pki.signMsg(signMsgVal);
	//System.out.println(signMsg);
%>

<%!public String appendParam(String returns, String paramId, String paramValue) {
		if (returns != "") {
			if (paramValue != "") {

				returns += "&" + paramId + "=" + paramValue;
			}

		} else {

			if (paramValue != "") {
				returns = paramId + "=" + paramValue;
			}
		}

		return returns;
	}%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title></title>
	</head>
	<body>
		<div align="center">
			<h2 align="center">提交到快钱页面</h2>
			<font color="#ff0000">（该页面仅做参考）</font>
    		<table width="500" border="1" style="border-collapse: collapse" bordercolor="green" align="center">
				<tr>
					<td align="center">
						分账确认订单号
					</td>
					<td align="center">
						<%=orderId%>
					</td>
				</tr>
				
				<tr>
					<td align="center">
						新手续费主收款方
					</td>
					<td align="center">
						<%=feePayer%>
					</td>
				</tr>
			
				<tr>
					<td align="center">
						平台商户编号
					</td>
					<td align="center">
						<%= merchantAcctId%>
					</td>
				</tr>
				<tr>
					<td align="center">
						新分账明细
					</td>
					<td align="center">
						<%=sharingData%>
					</td>
				</tr>
			</table>
		</div>
		<div align="center" style="font-weight: bold;">
			<form name="kqPay" action="https://sandbox.99bill.com/gatewayapi/sharingModify.htm" method="get">
				<input type="hidden" name="inputCharset" value="<%=inputCharset%>" />
				<input type="hidden" name="version" value="<%=version%>" />			
				<input type="hidden" name="signType" value="<%=signType%>" />
				<input type="hidden" name="merchantAcctId" value="<%=merchantAcctId%>" />		
				<input type="hidden" name="orderId" value="<%=orderId%>" />
				<input type="hidden" name="feePayer" value="<%=feePayer%>" />
    			<input type="hidden" name="sharingData" value="<%=sharingData%>"  />	
    			<input type="hidden" name="signMsg" value="<%=signMsg%>" />	
				

			<input type="submit" name="submit" value="提交到快钱">
			</form>
		</div>
	</body>
</html>
